<HTML>
<BODY BGCOLOR="white">
<PRE>
<FONT color="green">001</FONT>    package org.wattdepot.simulation.oahugrid.powerplant;<a name="line.1"></a>
<FONT color="green">002</FONT>    <a name="line.2"></a>
<FONT color="green">003</FONT>    import java.util.Calendar;<a name="line.3"></a>
<FONT color="green">004</FONT>    import org.wattdepot.simulation.oahugrid.strategy.SimulationEntry;<a name="line.4"></a>
<FONT color="green">005</FONT>    <a name="line.5"></a>
<FONT color="green">006</FONT>    /**<a name="line.6"></a>
<FONT color="green">007</FONT>     * Represents all of the power generation plants in this simulation.<a name="line.7"></a>
<FONT color="green">008</FONT>     * Note the following table of plants, capacities, and carbon intensities:<a name="line.8"></a>
<FONT color="green">009</FONT>     * &lt;pre&gt;<a name="line.9"></a>
<FONT color="green">010</FONT>     * Plant(s)     Capacity    Carbon   Type<a name="line.10"></a>
<FONT color="green">011</FONT>     * Waiau 9-10     100        2,400   Peaking<a name="line.11"></a>
<FONT color="green">012</FONT>     * Honolulu 8-9   105        2,240   Cycling<a name="line.12"></a>
<FONT color="green">013</FONT>     * AES            180        2,120   Baseload<a name="line.13"></a>
<FONT color="green">014</FONT>     * Kalaeloa       200        2,050   Baseload<a name="line.14"></a>
<FONT color="green">015</FONT>     * Waiau 5-6      108        1,800   Cycling<a name="line.15"></a>
<FONT color="green">016</FONT>     * Waiau 7-8      184        1,800   Baseload<a name="line.16"></a>
<FONT color="green">017</FONT>     * Kahe 1-6       595        1,744   Baseload <a name="line.17"></a>
<FONT color="green">018</FONT>     * HPOWER          45          150   Baseload<a name="line.18"></a>
<FONT color="green">019</FONT>     * &lt;/pre&gt;<a name="line.19"></a>
<FONT color="green">020</FONT>    <a name="line.20"></a>
<FONT color="green">021</FONT>     * @author Philip Johnson<a name="line.21"></a>
<FONT color="green">022</FONT>     */<a name="line.22"></a>
<FONT color="green">023</FONT>    public enum PowerPlant {<a name="line.23"></a>
<FONT color="green">024</FONT>      /** The Kahe baseload plants. */<a name="line.24"></a>
<FONT color="green">025</FONT>      SIM_KAHE_1 (Type.BASELOAD, 88, 8, 4),<a name="line.25"></a>
<FONT color="green">026</FONT>      /** The Kahe baseload plants. */<a name="line.26"></a>
<FONT color="green">027</FONT>      SIM_KAHE_2 (Type.BASELOAD, 88, 8, 4),<a name="line.27"></a>
<FONT color="green">028</FONT>      /** The Kahe baseload plants. */<a name="line.28"></a>
<FONT color="green">029</FONT>      SIM_KAHE_3 (Type.BASELOAD, 88, 8, 4),<a name="line.29"></a>
<FONT color="green">030</FONT>      /** The Kahe baseload plants. */<a name="line.30"></a>
<FONT color="green">031</FONT>      SIM_KAHE_4 (Type.BASELOAD, 88, 8, 4),<a name="line.31"></a>
<FONT color="green">032</FONT>      /** The Kahe baseload plants. */<a name="line.32"></a>
<FONT color="green">033</FONT>      SIM_KAHE_5 (Type.BASELOAD, 88, 8, 4),<a name="line.33"></a>
<FONT color="green">034</FONT>      /** The Kahe baseload plants. */<a name="line.34"></a>
<FONT color="green">035</FONT>      SIM_KAHE_6 (Type.BASELOAD, 135, 20, 8),<a name="line.35"></a>
<FONT color="green">036</FONT>      /** The Kahe spinning reserve plant. */<a name="line.36"></a>
<FONT color="green">037</FONT>      SIM_KAHE_7 (Type.SPINNINGRESERVE, 135, 20, 8),<a name="line.37"></a>
<FONT color="green">038</FONT>      /** The Waiau baseload plants. */<a name="line.38"></a>
<FONT color="green">039</FONT>      SIM_WAIAU_7 (Type.BASELOAD, 88, 8, 4),<a name="line.39"></a>
<FONT color="green">040</FONT>      /** The Waiau baseload plants. */<a name="line.40"></a>
<FONT color="green">041</FONT>      SIM_WAIAU_8 (Type.BASELOAD, 88, 8, 4),<a name="line.41"></a>
<FONT color="green">042</FONT>      /** The HPOWER baseload plant. */<a name="line.42"></a>
<FONT color="green">043</FONT>      SIM_HPOWER (Type.BASELOAD, 46, 5, 5),<a name="line.43"></a>
<FONT color="green">044</FONT>      /** The AES baseload plant. */<a name="line.44"></a>
<FONT color="green">045</FONT>      SIM_AES (Type.BASELOAD, 180, 20, 5),<a name="line.45"></a>
<FONT color="green">046</FONT>      /** The Kalaeloa baseload plant. */<a name="line.46"></a>
<FONT color="green">047</FONT>      SIM_KALAELOA (Type.BASELOAD, 200, 20, 5),<a name="line.47"></a>
<FONT color="green">048</FONT>      /** The Waiau cycling plants. */<a name="line.48"></a>
<FONT color="green">049</FONT>      SIM_WAIAU_5 (Type.CYCLING, 54, 0, 0),<a name="line.49"></a>
<FONT color="green">050</FONT>      /** The Waiau cycling plants. */<a name="line.50"></a>
<FONT color="green">051</FONT>      SIM_WAIAU_6 (Type.CYCLING, 54, 0, 0),<a name="line.51"></a>
<FONT color="green">052</FONT>      /** The Honolulu cycling plants. */<a name="line.52"></a>
<FONT color="green">053</FONT>      SIM_HONOLULU_8 (Type.CYCLING, 53, 0, 0),<a name="line.53"></a>
<FONT color="green">054</FONT>      /** The Honolulu cycling plants. */<a name="line.54"></a>
<FONT color="green">055</FONT>      SIM_HONOLULU_9 (Type.CYCLING, 53, 0, 0),<a name="line.55"></a>
<FONT color="green">056</FONT>      /** The Waiau peaking plant. */<a name="line.56"></a>
<FONT color="green">057</FONT>      SIM_WAIAU_9 (Type.PEAKING, 51, 0, 0),<a name="line.57"></a>
<FONT color="green">058</FONT>      /** The Waiau peaking plant. */<a name="line.58"></a>
<FONT color="green">059</FONT>      SIM_WAIAU_10 (Type.PEAKING, 51, 0, 0);<a name="line.59"></a>
<FONT color="green">060</FONT>    <a name="line.60"></a>
<FONT color="green">061</FONT>      /** Each power generator must be one of the following types. */<a name="line.61"></a>
<FONT color="green">062</FONT>      public enum Type { BASELOAD, CYCLING, PEAKING, SPINNINGRESERVE };<a name="line.62"></a>
<FONT color="green">063</FONT>      <a name="line.63"></a>
<FONT color="green">064</FONT>      /** The type of this power plant. */<a name="line.64"></a>
<FONT color="green">065</FONT>      private Type type;<a name="line.65"></a>
<FONT color="green">066</FONT>      /** The maximum MW that this plant can produce. */<a name="line.66"></a>
<FONT color="green">067</FONT>      private int maxMW;<a name="line.67"></a>
<FONT color="green">068</FONT>      /** The minimum MW that this plant can produce. Baseload plants have a non-zero minimum.*/ <a name="line.68"></a>
<FONT color="green">069</FONT>      //private int minMW;<a name="line.69"></a>
<FONT color="green">070</FONT>      /** The amount of MW generated by this plant that goes to running the plant. */<a name="line.70"></a>
<FONT color="green">071</FONT>      private int overheadMW;<a name="line.71"></a>
<FONT color="green">072</FONT>      /** The total energy generated by this plant so far. */<a name="line.72"></a>
<FONT color="green">073</FONT>      private double energyGeneratedToDate = 0;<a name="line.73"></a>
<FONT color="green">074</FONT>    <a name="line.74"></a>
<FONT color="green">075</FONT>    <a name="line.75"></a>
<FONT color="green">076</FONT>      /**<a name="line.76"></a>
<FONT color="green">077</FONT>       * Creates a new power plant with given specifications.<a name="line.77"></a>
<FONT color="green">078</FONT>       * @param type The type of plant.<a name="line.78"></a>
<FONT color="green">079</FONT>       * @param maxMW The maximum MW output.<a name="line.79"></a>
<FONT color="green">080</FONT>       * @param minMW The minimum MW output. <a name="line.80"></a>
<FONT color="green">081</FONT>       * @param overheadMW The MW used for overhead.<a name="line.81"></a>
<FONT color="green">082</FONT>       */<a name="line.82"></a>
<FONT color="green">083</FONT>      private PowerPlant(Type type, int maxMW, int minMW, int overheadMW) {<a name="line.83"></a>
<FONT color="green">084</FONT>        this.type = type;<a name="line.84"></a>
<FONT color="green">085</FONT>        this.maxMW = maxMW;<a name="line.85"></a>
<FONT color="green">086</FONT>        //this.minMW = minMW;<a name="line.86"></a>
<FONT color="green">087</FONT>        this.overheadMW = overheadMW;<a name="line.87"></a>
<FONT color="green">088</FONT>      }<a name="line.88"></a>
<FONT color="green">089</FONT>      <a name="line.89"></a>
<FONT color="green">090</FONT>      /**<a name="line.90"></a>
<FONT color="green">091</FONT>       * Returns the type of plant.<a name="line.91"></a>
<FONT color="green">092</FONT>       * @return The type.<a name="line.92"></a>
<FONT color="green">093</FONT>       */<a name="line.93"></a>
<FONT color="green">094</FONT>      public Type getType() {<a name="line.94"></a>
<FONT color="green">095</FONT>        return this.type;<a name="line.95"></a>
<FONT color="green">096</FONT>      }<a name="line.96"></a>
<FONT color="green">097</FONT>      <a name="line.97"></a>
<FONT color="green">098</FONT>      /**<a name="line.98"></a>
<FONT color="green">099</FONT>       * Given a request for power in MW, return the amount of MW that this plant can provide. <a name="line.99"></a>
<FONT color="green">100</FONT>       * Requests for 0 or negative MW return 0;<a name="line.100"></a>
<FONT color="green">101</FONT>       * @param requestedMW The requested amount of power.<a name="line.101"></a>
<FONT color="green">102</FONT>       * @return The power that this plant can provide, in MW. <a name="line.102"></a>
<FONT color="green">103</FONT>       */<a name="line.103"></a>
<FONT color="green">104</FONT>      public int provideMW(int requestedMW) {<a name="line.104"></a>
<FONT color="green">105</FONT>        if (requestedMW &lt;= 0) {<a name="line.105"></a>
<FONT color="green">106</FONT>          return 0;<a name="line.106"></a>
<FONT color="green">107</FONT>        }<a name="line.107"></a>
<FONT color="green">108</FONT>        else if (requestedMW &gt; maxMW) {<a name="line.108"></a>
<FONT color="green">109</FONT>          return maxMW;<a name="line.109"></a>
<FONT color="green">110</FONT>        }<a name="line.110"></a>
<FONT color="green">111</FONT>        /*  Don't do minimums now, too confusing.<a name="line.111"></a>
<FONT color="green">112</FONT>        else if (requestedMW &lt; minMW) {<a name="line.112"></a>
<FONT color="green">113</FONT>          return minMW;<a name="line.113"></a>
<FONT color="green">114</FONT>        }<a name="line.114"></a>
<FONT color="green">115</FONT>        */<a name="line.115"></a>
<FONT color="green">116</FONT>        else {<a name="line.116"></a>
<FONT color="green">117</FONT>          return requestedMW;<a name="line.117"></a>
<FONT color="green">118</FONT>        }<a name="line.118"></a>
<FONT color="green">119</FONT>      }<a name="line.119"></a>
<FONT color="green">120</FONT>      <a name="line.120"></a>
<FONT color="green">121</FONT>      /**<a name="line.121"></a>
<FONT color="green">122</FONT>       * Returns the MW generated for overhead.<a name="line.122"></a>
<FONT color="green">123</FONT>       * @return The overhead power.<a name="line.123"></a>
<FONT color="green">124</FONT>       */<a name="line.124"></a>
<FONT color="green">125</FONT>      public int getOverheadMW() {<a name="line.125"></a>
<FONT color="green">126</FONT>        return this.overheadMW;<a name="line.126"></a>
<FONT color="green">127</FONT>      }<a name="line.127"></a>
<FONT color="green">128</FONT>      <a name="line.128"></a>
<FONT color="green">129</FONT>      /**<a name="line.129"></a>
<FONT color="green">130</FONT>       * Returns the maximum MW this plant can provide to the grid.<a name="line.130"></a>
<FONT color="green">131</FONT>       * @return The maximum power.<a name="line.131"></a>
<FONT color="green">132</FONT>       */<a name="line.132"></a>
<FONT color="green">133</FONT>      public int getMaxMW() {<a name="line.133"></a>
<FONT color="green">134</FONT>        return this.maxMW;<a name="line.134"></a>
<FONT color="green">135</FONT>      }<a name="line.135"></a>
<FONT color="green">136</FONT>    <a name="line.136"></a>
<FONT color="green">137</FONT>      /**<a name="line.137"></a>
<FONT color="green">138</FONT>       * Returns a SimulationEntry for this power plant. The plant will provide as much of the <a name="line.138"></a>
<FONT color="green">139</FONT>       * requestedMW as it can.<a name="line.139"></a>
<FONT color="green">140</FONT>       * Note that this method does not take into account minMW, overhead, or spinning reserve.<a name="line.140"></a>
<FONT color="green">141</FONT>       * @param requestedMW The requested MW. This can be zero, in which case the power plant<a name="line.141"></a>
<FONT color="green">142</FONT>       * creates an entry indicating its overhead power.<a name="line.142"></a>
<FONT color="green">143</FONT>       * @param timestamp The timestamp when power is required.<a name="line.143"></a>
<FONT color="green">144</FONT>       * @return The SimulationEntry instance representing the power provided by this plant.<a name="line.144"></a>
<FONT color="green">145</FONT>       */<a name="line.145"></a>
<FONT color="green">146</FONT>      public SimulationEntry getSimulationEntry(int requestedMW, Calendar timestamp) {<a name="line.146"></a>
<FONT color="green">147</FONT>        return new SimulationEntry(timestamp.getTimeInMillis(), this, <a name="line.147"></a>
<FONT color="green">148</FONT>            this.provideMW(requestedMW), this.overheadMW);<a name="line.148"></a>
<FONT color="green">149</FONT>      }<a name="line.149"></a>
<FONT color="green">150</FONT>    <a name="line.150"></a>
<FONT color="green">151</FONT>      /**<a name="line.151"></a>
<FONT color="green">152</FONT>       * Updates this plant's total generated energy by additional energy.<a name="line.152"></a>
<FONT color="green">153</FONT>       * @param additionalEnergy The additional energy (in MWh) to be added.<a name="line.153"></a>
<FONT color="green">154</FONT>       */<a name="line.154"></a>
<FONT color="green">155</FONT>      public void incrementEnergyGeneratedToDate(long additionalEnergy) {<a name="line.155"></a>
<FONT color="green">156</FONT>        this.energyGeneratedToDate += additionalEnergy;<a name="line.156"></a>
<FONT color="green">157</FONT>      }<a name="line.157"></a>
<FONT color="green">158</FONT>    <a name="line.158"></a>
<FONT color="green">159</FONT>      /** <a name="line.159"></a>
<FONT color="green">160</FONT>       * Returns the total energy generated by this plant so far in the simulation. <a name="line.160"></a>
<FONT color="green">161</FONT>       * @return The total energy. <a name="line.161"></a>
<FONT color="green">162</FONT>       */<a name="line.162"></a>
<FONT color="green">163</FONT>      public double getEnergyGeneratedToDate() {<a name="line.163"></a>
<FONT color="green">164</FONT>        return energyGeneratedToDate;<a name="line.164"></a>
<FONT color="green">165</FONT>      }<a name="line.165"></a>
<FONT color="green">166</FONT>      <a name="line.166"></a>
<FONT color="green">167</FONT>      /**<a name="line.167"></a>
<FONT color="green">168</FONT>       * Provide an initial value for energy generated for this PowerPlant. It should be <a name="line.168"></a>
<FONT color="green">169</FONT>       * retrieved from WattDepot.<a name="line.169"></a>
<FONT color="green">170</FONT>       * @param energy The initial energy generated value. <a name="line.170"></a>
<FONT color="green">171</FONT>       */<a name="line.171"></a>
<FONT color="green">172</FONT>      public void initializeEnergyGeneratedToDate(Double energy) {<a name="line.172"></a>
<FONT color="green">173</FONT>        this.energyGeneratedToDate = energy;<a name="line.173"></a>
<FONT color="green">174</FONT>        <a name="line.174"></a>
<FONT color="green">175</FONT>      }<a name="line.175"></a>
<FONT color="green">176</FONT>    <a name="line.176"></a>
<FONT color="green">177</FONT>    }<a name="line.177"></a>




























































</PRE>
</BODY>
</HTML>
